
package interfaz;

import java.awt.Color;
import java.awt.Component;
import javax.swing.JTable;
import javax.swing.table.DefaultTableCellRenderer;


public class ColoreaCeldas extends DefaultTableCellRenderer
{
   @Override
   public Component getTableCellRendererComponent(JTable table,
      Object value,
      boolean isSelected,
      boolean hasFocus,
      int row,
      int column)
   {
      super.getTableCellRendererComponent (table, value, isSelected, hasFocus, row, column);
      if(isSelected){
      this.setForeground(Color.BLACK);}
      if(!hasFocus){
      if ( ((String)value).equals("FS"))   {
        
          this.setBackground(Color.GRAY);
         // this.setForeground(Color.YELLOW); para el color de la letra
      } else if ( ((String)value).equals("D"))   {
        
          this.setBackground(Color.GREEN);
         // this.setForeground(Color.YELLOW); para el color de la letra
      }
      else if ( ((String)value).equals("R"))   {
        
          this.setBackground(Color.YELLOW);
         // this.setForeground(Color.YELLOW); para el color de la letra
      }
      else if ( ((String)value).equals("O"))   {
        
          this.setBackground(Color.RED);
          
         // this.setForeground(Color.YELLOW); para el color de la letra
      }
        else {
          // Restaurar los valores por defecto
           this.setBackground(Color.WHITE);
      }
      }
      else if(hasFocus){this.setBackground(Color.BLUE);}
         
  
      
      
    

      return this;
   }
}